TimeSeries DataAnalytics Tutorial

In [1]:
%matplotlib inline

import visdom
import numpy as np
import chart_studio.plotly as py
import plotly.express as px
import plotly.tools as tls
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import pandas as pd
from datetime import datetime
import requests
import json
import matplotlib.pyplot as plt
In [2]:
import sys
sys.path.append("../TimeSeriesTools")
import mongodb_utils
db_host= 'localhost'
port = '28018'
db_name='TimeSeriesBench'
mongodb_client = mongodb_utils.mongodb_connect(db_host, port)
Trying to connect to MongoDB server: localhost on port: 28018
In [3]:
import kairosdb_utils
global kairosdb_server 
kairosdb_server = "http://localhost:6060"
In [4]:
import influxdb_utils
db_host= 'localhost'
port = '9086'
db_name='TimeSeriesBench'
influxdb_client = influxdb_utils.influxdb_connect(db_host, port)
Trying to connect to InfluxDB server without proxy: localhost on port: 9086
connection sucess!
In [5]:
import warp10_utils
global warp10_server 
warp10_server = "http://localhost:7070"
In [6]:
def get_collection_scheme(db_name,scheme_name):
    db = mongodb_client[db_name]
    schemes_coll = db['schemes']
    scheme = schemes_coll.find({"name":scheme_name})
    return scheme
In [7]:
def mongodb_find_all_data(db_name,coll_name,scheme):
    data = mongodb_utils.get_all_data(mongodb_client,db_name,coll_name,scheme)
    return data
In [8]:
def mongodb_find_data_select_by_tags(db_name,coll_name,tags,scheme):
    data = mongodb_utils.get_data_select_by_tags(mongodb_client,db_name,coll_name,tags,scheme)
    return data
In [9]:
def kairosdb_find_all_data(db_name,coll_name,scheme):
    data = kairosdb_utils.get_all_data(kairosdb_server,db_name,coll_name,scheme)
    return data
In [10]:
def influxdb_find_all_data(db_name,coll_name,scheme):
    data = influxdb_utils.get_all_data(influxdb_client,db_name,coll_name,scheme)
    return data
In [11]:
def warp10_find_all_data(db_name,coll_name,scheme):
    data = warp10_utils.get_all_data(warp10_server,db_name,coll_name)
    return data
In [12]:
def clean_data(scheme,data):
    from cerberus import Validator
    v = Validator(scheme)
    for index,item in enumerate(data,start=0):
        res = v.validate(item)
        if (res == False):
            print("corrupt data in line :",index,", error : ",v.errors)
            del data[index]
In [13]:
def str_to_unix(date):
    dt = datetime.strptime(date, '%d/%m/%Y %H:%M:%S')
    epoch = datetime.utcfromtimestamp(0)
    return int((dt - epoch).total_seconds()) * 1000
In [14]:
def to_unix_time(dt):
    epoch =  datetime.utcfromtimestamp(7200)
    return (dt - epoch).total_seconds() * 1000
In [15]:
def str_to_timestamp(date):
    dt = datetime.strptime(date, '%d/%m/%Y %H:%M:%S')
    d0 = datetime(2019,1,1,0,0,0,0)
    return int((dt - d0).total_seconds())
In [16]:
def type_convert(df):
    head = df.columns
    for i in range(1,len(head)) : 
        df[head[i]] = pd.to_numeric(df[head[i]])

I/ Requete des données

A/ Données SmartGrid

In [17]:
scheme = get_collection_scheme(db_name,'SmartGrid')
In [18]:
scheme[0]['value']
Out[18]:
{'timestamp': {'type': 'string', 'required': True, 'empty': False},
 'tagname': {'type': 'string', 'required': True, 'empty': False},
 'value': {'type': 'string', 'required': True, 'empty': False},
 'quality': {'type': 'string', 'required': True, 'empty': False}}

MongoDB

In [19]:
%%time
coll_name='SmartGridCryolite20190101OneMonthBS10000d'
data = mongodb_find_all_data(db_name,coll_name,scheme[0]['value'])
print("number of docs",len(data))
769598  documents found
number of docs 769598
CPU times: user 3.76 s, sys: 317 ms, total: 4.08 s
Wall time: 4.35 s
In [20]:
%%time
coll_name='SmartGridCryolite20190101OneMonthBS10000d'
tags = { 'Buiding' : 'CRY', 'Device' : 'CENTRALE_SOLAIRE', 'Measure' : 'CRY_act_prod_pow' }
data = mongodb_find_data_select_by_tags(db_name,coll_name,tags,scheme[0]['value'])
print("number of docs",len(data))
27584  documents found
number of docs 27584
CPU times: user 338 ms, sys: 76.4 ms, total: 414 ms
Wall time: 729 ms

KairosDB

In [32]:
%%time
coll_name='SmartGridCryolite20190101OneMonthV10000'
data = kairosdb_find_all_data(db_name,coll_name,scheme[0]['value'])
print("number of docs",len(data))
number of docs 769598
CPU times: user 2.24 s, sys: 202 ms, total: 2.45 s
Wall time: 23 s

InfluxDB

In [33]:
%%time
coll_name='SmartGridCryolite20190101OneMonthBS10000d'
data = influxdb_find_all_data(db_name,coll_name,scheme[0]['value'])
print("number of docs",len(data))
number of docs 769598
CPU times: user 3.56 s, sys: 289 ms, total: 3.85 s
Wall time: 8.52 s

Wrap10

In [229]:
%%time
coll_name='SmartGridCryolite20190101OneMonthBS1000'
data = warp10_find_all_data(db_name,coll_name,scheme[0]['value'])
print("number of docs",len(data))
REQUEST: //store read token in a variable
'S5zdwM9mzVKTdNzYMxcRixZtSyHAHNWR01ylzR0dNOP2g4zLj.yvqH4GNlnKbamRiDrdnfXu4FOpgVO0kxRUGHPEYmd4LC_wHjG67GaY4cmmVpDF.QHvmiISjEQGDjiLx35C8FEmq2ljyFAtvRu4RNqSffN8HChp326rXaAVjh4jiB9Rpuoo2.' 'Rt' STORE
[
  $Rt
  'SmartGridCryolite20190101OneMonthBS1000'
  {} 
  NOW MINLONG 1 +
] FETCH
Status code: 200
number of docs 1
CPU times: user 230 ms, sys: 45.2 ms, total: 275 ms
Wall time: 624 ms
In [ ]:
%%time
clean_data(scheme[0]['value'],data)

Parse des données

In [21]:
%%time
df = pd.DataFrame(data)
df[0:5]
CPU times: user 30.7 ms, sys: 0 ns, total: 30.7 ms
Wall time: 29.4 ms
Out[21]:
_id timestamp tagname value quality
0 5ee88bbd6c4da78fed9f3449 01/01/2019 09:15:12 CRY.CENTRALE_SOLAIRE.CRY_act_prod_pow 1.000000000 100.0
1 5ee88bbd6c4da78fed9f344a 01/01/2019 09:15:18 CRY.CENTRALE_SOLAIRE.CRY_act_prod_pow 0.000000000 100.0
2 5ee88bbd6c4da78fed9f344b 01/01/2019 09:15:37 CRY.CENTRALE_SOLAIRE.CRY_act_prod_pow 1.000000000 100.0
3 5ee88bbd6c4da78fed9f344c 01/01/2019 09:15:43 CRY.CENTRALE_SOLAIRE.CRY_act_prod_pow 0.000000000 100.0
4 5ee88bbd6c4da78fed9f344d 01/01/2019 09:15:53 CRY.CENTRALE_SOLAIRE.CRY_act_prod_pow 1.000000000 100.0
In [22]:
df.tagname.unique()
Out[22]:
array(['CRY.CENTRALE_SOLAIRE.CRY_act_prod_pow'], dtype=object)
In [23]:
df['timestamp'] = df['timestamp'].apply(str_to_timestamp)
In [24]:
df['day-id'] = df['timestamp']//(3600*24)
In [25]:
df['hour-id'] = df['timestamp'] % (3600*24) // 3600
In [26]:
df['hour-id'].unique()
Out[26]:
array([ 9, 10, 11, 12, 13, 14, 15, 16,  8, 17])
In [27]:
df['value'] = pd.to_numeric(df['value'])
df['hour-id'] = pd.to_numeric(df['hour-id'])
In [28]:
import matplotlib.colors as mcolors
color_names = [ c for c in mcolors.CSS4_COLORS.keys()]
In [29]:
def compute_curve(df,day_id,tagname):
    day_df = df.loc[(df['day-id'] == day_id) & (df['tagname'] == tagname )]
    vh_df = day_df[['hour-id','value']].groupby('hour-id').mean().reset_index().sort_values(by='hour-id')
    x = vh_df['hour-id']
    y = vh_df['value']
    return x,y

def plot_curve(df,day_id,tagname,color_names,fig):
    x , y = compute_curve(df,day_id,tagname)
    nb_points = len(x)
    fig.add_trace(go.Scatter(x=x,y=y,name="Value"+tagname+"Day"+str(day_id),
                            line_color=color_names[day_id],
                            opacity=0.8))
    # Use date string to set xaxis range
    fig.update_layout(title_text="day smartgrid data series")
    
In [30]:
%%time
day_id = 10
tagname = 'CRY.CENTRALE_SOLAIRE.CRY_act_prod_pow'
fig = go.Figure()
plot_curve(df,day_id,tagname,color_names,fig)
fig.show()
CPU times: user 720 ms, sys: 81.9 ms, total: 802 ms
Wall time: 2.18 s
In [31]:
%%time
fig = go.Figure()
for day_id in range(30):
    plot_curve(df,day_id,tagname,color_names,fig)
fig.show()
CPU times: user 529 ms, sys: 8.66 ms, total: 538 ms
Wall time: 535 ms

B/ Données Eolienne

In [251]:
scheme = get_collection_scheme(db_name,'WindProp')
In [252]:
scheme[0]['value']
Out[252]:
{'Heure': {'type': 'string', 'required': True, 'empty': False},
 'Temps écoulé': {'type': 'string', 'required': True, 'empty': False},
 '4069 state': {'type': 'string', 'required': True, 'empty': False},
 'Battery voltage': {'type': 'string', 'required': True, 'empty': False},
 'Flow SP': {'type': 'string', 'required': True, 'empty': False},
 'Unit Code': {'type': 'string', 'required': True, 'empty': False},
 'Flow M': {'type': 'string', 'required': True, 'empty': False},
 'Pressure1': {'type': 'string', 'required': True, 'empty': False},
 'Temperature1': {'type': 'string', 'required': True, 'empty': False},
 'Latitude': {'type': 'string', 'required': True, 'empty': False},
 'Longitude': {'type': 'string', 'required': True, 'empty': False},
 'Altitude': {'type': 'string', 'required': True, 'empty': False},
 'Head_Rel_True North': {'type': 'string', 'required': True, 'empty': False},
 'Pressure2': {'type': 'string', 'required': True, 'empty': False},
 'Temperature2': {'type': 'string', 'required': True, 'empty': False},
 'Humidity': {'type': 'string', 'required': True, 'empty': False},
 'MDA Wnd Dir': {'type': 'string', 'required': True, 'empty': False},
 'MDA Wnd Speed': {'type': 'string', 'required': True, 'empty': False},
 'MWD Wind Dir': {'type': 'string', 'required': True, 'empty': False},
 'MWD Wind Speed': {'type': 'string', 'required': True, 'empty': False},
 'Gaz Concentration 1': {'type': 'string', 'required': True, 'empty': False},
 'Gaz Concentration 2': {'type': 'string', 'required': True, 'empty': False},
 'Gaz Concentration 3': {'type': 'string', 'required': True, 'empty': False},
 'Gaz Concentration 4': {'type': 'string', 'required': True, 'empty': False},
 'SPA 1': {'type': 'string', 'required': True, 'empty': False},
 'SPA 2': {'type': 'string', 'required': True, 'empty': False},
 'Cellule Photo': {'type': 'string', 'required': True, 'empty': False},
 'Temperature3': {'type': 'string', 'required': True, 'empty': False},
 'Pressure3': {'type': 'string', 'required': True, 'empty': False},
 'Flow MassFlow 1': {'type': 'string', 'required': True, 'empty': False},
 'NOTUSED Flow MassFlow 2': {'type': 'string',
  'required': True,
  'empty': False},
 'Flow': {'type': 'string', 'required': True, 'empty': False},
 'Humidity2': {'type': 'string', 'required': True, 'empty': False},
 'Test': {'type': 'string', 'required': True, 'empty': False},
 'Details': {'type': 'string', 'required': True, 'empty': False},
 'SPA 3': {'type': 'string', 'required': True, 'empty': False},
 'SPA 4': {'type': 'string', 'required': True, 'empty': False},
 'CavityPressure': {'type': 'string', 'required': True, 'empty': False},
 'CavityTemp': {'type': 'string', 'required': True, 'empty': False},
 'CH4': {'type': 'string', 'required': True, 'empty': False},
 'CH4_dry': {'type': 'string', 'required': True, 'empty': False},
 'C2H6': {'type': 'string', 'required': True, 'empty': False},
 'C2H6_dry': {'type': 'string', 'required': True, 'empty': False},
 '13CH4': {'type': 'string', 'required': True, 'empty': False},
 'H2O': {'type': 'string', 'required': True, 'empty': False},
 'CO2': {'type': 'string', 'required': True, 'empty': False},
 'C2C1Ratio': {'type': 'string', 'required': True, 'empty': False},
 'Delta_iCH4_Raw': {'type': 'string', 'required': True, 'empty': False},
 'HP_Delta_iCH4_30s': {'type': 'string', 'required': True, 'empty': False},
 'HP_Delta_iCH4_2min': {'type': 'string', 'required': True, 'empty': False},
 'HP_Delta_iCH4_5min': {'type': 'string', 'required': True, 'empty': False},
 '_id': ObjectId('5ef1d85303b14cb959702ca5')}
In [259]:
%%time
coll_name='WindPropLacqOneDayP25B1000test'
data = mongodb_find_all_data(db_name,coll_name,scheme[0]['value'])
print("number of docs",len(data))
7288  documents found
number of docs 7288
CPU times: user 145 ms, sys: 4 ms, total: 149 ms
Wall time: 161 ms
In [254]:
%%time
coll_name='WindPropLacqOneDayP25BS100'
data = kairosdb_find_all_data(db_name,coll_name,scheme[0]['value'])
print("number of docs",len(data))
number of docs 7285
CPU times: user 133 ms, sys: 5 ms, total: 138 ms
Wall time: 1.57 s
In [255]:
%%time
coll_name='WindPropLacqOneDayP25BS100c'
data = influxdb_find_all_data(db_name,coll_name,scheme[0]['value'])
print("number of docs",len(data))
number of docs 7285
CPU times: user 162 ms, sys: 1 ms, total: 163 ms
Wall time: 925 ms
In [256]:
%%time
coll_name='WindPropLacqOneDayP25BS1000test'
data = warp10_find_all_data(db_name,coll_name,scheme[0]['value'])
print("number of docs",len(data[0][0]['v']))
REQUEST: //store read token in a variable
'S5zdwM9mzVKTdNzYMxcRixZtSyHAHNWR01ylzR0dNOP2g4zLj.yvqH4GNlnKbamRiDrdnfXu4FOpgVO0kxRUGHPEYmd4LC_wHjG67GaY4cmmVpDF.QHvmiISjEQGDjiLx35C8FEmq2ljyFAtvRu4RNqSffN8HChp326rXaAVjh4jiB9Rpuoo2.' 'Rt' STORE
[
  $Rt
  'WindPropLacqOneDayP25BS1000test'
  {} 
  NOW MINLONG 1 +
] FETCH
Status code: 200
number of docs 7285
CPU times: user 65.8 ms, sys: 4 ms, total: 69.8 ms
Wall time: 584 ms
In [260]:
%%time
df = pd.DataFrame(data)
df[0:5]
CPU times: user 213 ms, sys: 2.99 ms, total: 216 ms
Wall time: 223 ms
Out[260]:
_id Heure Temps écoulé 4069 state Battery voltage Flow SP Unit Code Flow M Pressure1 Temperature1 ... C2H6 C2H6_dry 13CH4 H2O CO2 C2C1Ratio Delta_iCH4_Raw HP_Delta_iCH4_30s HP_Delta_iCH4_2min HP_Delta_iCH4_5min
0 5ef20806ac8e8f5b304674be 02/10/2019 09:11:02 0 1.010000 888888.00 9.00 17.00 0.00 1.008 19.933 ... 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
1 5ef20806ac8e8f5b304674bf 02/10/2019 09:11:03 1 1.010000 888888.00 9.00 17.00 0.00 1.008 19.955 ... 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
2 5ef20806ac8e8f5b304674c0 02/10/2019 09:11:04 2 1.010000 888888.00 9.00 17.00 0.00 1.008 19.955 ... 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
3 5ef20806ac8e8f5b304674c1 02/10/2019 09:11:05 3 1.010000 888888.00 9.00 17.00 0.00 1.008 19.944 ... 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
4 5ef20806ac8e8f5b304674c2 02/10/2019 09:11:06 4 1.010000 888888.00 9.00 17.00 0.00 1.008 19.944 ... 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

5 rows × 52 columns

In [261]:
axisX = df['Heure']
In [262]:
df['Heure'] = df['Heure'].apply(str_to_unix)
df[0:5]
Out[262]:
_id Heure Temps écoulé 4069 state Battery voltage Flow SP Unit Code Flow M Pressure1 Temperature1 ... C2H6 C2H6_dry 13CH4 H2O CO2 C2C1Ratio Delta_iCH4_Raw HP_Delta_iCH4_30s HP_Delta_iCH4_2min HP_Delta_iCH4_5min
0 5ef20806ac8e8f5b304674be 1570007462000 0 1.010000 888888.00 9.00 17.00 0.00 1.008 19.933 ... 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
1 5ef20806ac8e8f5b304674bf 1570007463000 1 1.010000 888888.00 9.00 17.00 0.00 1.008 19.955 ... 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
2 5ef20806ac8e8f5b304674c0 1570007464000 2 1.010000 888888.00 9.00 17.00 0.00 1.008 19.955 ... 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
3 5ef20806ac8e8f5b304674c1 1570007465000 3 1.010000 888888.00 9.00 17.00 0.00 1.008 19.944 ... 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
4 5ef20806ac8e8f5b304674c2 1570007466000 4 1.010000 888888.00 9.00 17.00 0.00 1.008 19.944 ... 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

5 rows × 52 columns

In [263]:
type_convert(df)
In [264]:
df['MDA Wnd Speed'].describe()
Out[264]:
count    7288.000000
mean        2.980392
std         1.138444
min         0.200000
25%         2.200000
50%         2.800000
75%         3.500000
max         7.800000
Name: MDA Wnd Speed, dtype: float64
In [265]:
df['CavityTemp'].describe()
Out[265]:
count    7288.000000
mean       38.640956
std        15.677573
min         0.000000
25%        45.000000
50%        45.000000
75%        45.000000
max        45.030000
Name: CavityTemp, dtype: float64
In [266]:
df['CavityPressure'].describe()
Out[266]:
count    7288.000000
mean      268.270759
std       296.474344
min       147.970000
25%       148.000000
50%       148.000000
75%       148.000000
max       999.000000
Name: CavityPressure, dtype: float64
In [267]:
%matplotlib inline
nb_points=7200
x=axisX[0:nb_points]
fig = go.Figure()
fig.add_trace(go.Scatter(
                x=x,
                y=[item for item in df["MWD Wind Speed"][0:nb_points]],
                name="MWD Wind Speed",
                line_color='deepskyblue',
                opacity=0.8))

fig.add_trace(go.Scatter(
                x=x,
                y=[item for item in df["MDA Wnd Speed"][0:nb_points]],
                name="MDA Wnd Speed",
                line_color='dimgray',
                opacity=0.8))

# Use date string to set xaxis range
fig.update_layout(xaxis_range=[x[0],
                               x[nb_points-1]],
                  title_text="éolienne data series")
fig.show()
In [268]:
vis = visdom.Visdom()
vis.plotlyplot(fig, win="mywin3")
Setting up a new session...
Out[268]:
'mywin3'
In [269]:
fig = make_subplots(
    rows=3, cols=1, shared_xaxes=True, vertical_spacing=0.02
)

fig.add_trace(go.Scatter(
                x=x,
                y=[item for item in df["CavityTemp"][0:nb_points]],
                name="CavityTemp",
                line_color='deepskyblue',
                line_width = 2,
                opacity=0.8),
              row=1, col=1)

fig.add_trace(go.Scatter(
                x=x,
                y=[item for item in df["MWD Wind Speed"][0:nb_points]],
                name="MWD Wind Speed",
                line_color='dimgray',
                opacity=0.8),
              row=2, col=1)

fig.add_trace(go.Scatter(
                x=x,
                y=[item for item in df["Temperature1"][0:nb_points]],
                name="Temperature1",
                line_color='rgb(49,130,189)',
                line_width = 1.2,
                opacity=0.8),
              row=3, col=1)

fig.update_layout(height=1000, width=1000,
                  title_text="éolienne data series")
fig.show()
In [270]:
vis = visdom.Visdom()
vis.plotlyplot(fig, win="mywin3")
Setting up a new session...
Out[270]:
'mywin3'

II/ Statistiques

In [271]:
from sklearn.linear_model import LinearRegression
In [272]:
temp_ori = df['MDA Wnd Speed']
In [273]:
lr_x=df['Heure'].values.reshape(-1, 1) 
lr_y=df['MDA Wnd Speed'].values.reshape(-1, 1) 
In [274]:
lrModel = LinearRegression()
lrModel.fit(lr_x,lr_y)
Out[274]:
LinearRegression(copy_X=True, fit_intercept=True, n_jobs=None, normalize=False)
In [275]:
lrModel.score(lr_x,lr_y)
Out[275]:
0.16069674644762333
In [276]:
alpha = lrModel.intercept_[0]
alpha
Out[276]:
-340538.79077349487
In [277]:
beta = lrModel.coef_[0][0]
beta
Out[277]:
2.1690405244450767e-07
In [278]:
pred = alpha + beta*lr_x
pred
Out[278]:
array([[2.19010242],
       [2.19031933],
       [2.19053623],
       ...,
       [3.77024844],
       [3.77046535],
       [3.77068225]])
In [279]:
res = pred.reshape(7288,)
res
Out[279]:
array([2.19010242, 2.19031933, 2.19053623, ..., 3.77024844, 3.77046535,
       3.77068225])
In [280]:
wspeed_p = temp_ori - res
wspeed_p
Out[280]:
0      -0.490102
1       0.009681
2       0.009464
3       0.009247
4       1.209030
          ...   
7283    1.330185
7284    1.329968
7285    0.429752
7286    0.429535
7287    0.429318
Name: MDA Wnd Speed, Length: 7288, dtype: float64
In [281]:
fig, ax = plt.subplots(1, 1, figsize=(6, 3))
wspeed_p.plot(ax=ax, lw=.5)
#ax.set_ylim(1.99, 2.02)
ax.set_xlabel('Date')
ax.set_ylabel('wspeed after treatement')
Out[281]:
Text(0, 0.5, 'wspeed after treatement')

III/ FFT, PSD : analyse en fréquence du signal

Notebook FFTTuto illustrant l'utilisation des FFT et PSD sur des données temporelles

In [282]:
import scipy as sp
import scipy.fftpack
In [283]:
wspeed_p_fft = sp.fftpack.fft(wspeed_p.values)
In [284]:
#Calcul psd
wspeed_p_psd = np.abs(wspeed_p_fft) ** 2
In [285]:
fftfreq = sp.fftpack.fftfreq(len(wspeed_p_psd), 1. / 365*24*3600)
In [286]:
i = fftfreq > 0
In [287]:
fig, ax = plt.subplots(1, 1, figsize=(8, 4))
ax.plot(fftfreq[i], 10 * np.log10(wspeed_p_psd[i]))
ax.set_xlabel('Frequency (1/sec)')
ax.set_ylabel('PSD (dB)')
Out[287]:
Text(0, 0.5, 'PSD (dB)')
In [288]:
#Extraction des fréquences les plus importantes (FFT tronquée)
wspeed_p_fft_bis = wspeed_p_fft.copy()
wspeed_p_fft_bis[np.abs(fftfreq) > 0.00001] = 0
In [289]:
#Calcul de la courbe de température inverse de la FFT tronquée
wspeed_p_slow = np.real(sp.fftpack.ifft(wspeed_p_fft_bis))
fig, ax = plt.subplots(1, 1, figsize=(6, 3))
ax.plot(wspeed_p_slow, '-')
wspeed_p.plot(ax=ax, lw=.5)
ax.set_xlabel('Date')
ax.set_ylabel('Wind Speed')
Out[289]:
Text(0, 0.5, 'Wind Speed')